<?php

	
class DAL {
	
	// Определение настроек базы данных
	
/*	private $HOSTNAME;
    private $USERNAME;
    private $PASSWORD;
    private $DBNAME;
    private $TMESSAGES;
	private $TCOMMENTS;
	private $CHARSET;
	private $conn;*/
	
	Public $DBTYPE;
	
	/**
    * Конструктор класса
    *
    * Получает тип БД
    */
  public function __construct()
  {
		
   		$this->DBTYPE    = DB_TYPE;
			
					
  }
	
	//добавление сообщения в базу
	public function addMessage($message, $name)
	{
		$DB = new $this->DBTYPE;
	    $DB -> addMessage($message, $name); 
	
	}
	
    public function	addComent($messageid, $message, $name)
	{
		
		$DB = new $this->DBTYPE;
	    $DB -> addComent($messageid, $message, $name); 
	}
	
	public function change_message($messageid, $message, $name)
	{
		$DB = new $this->DBTYPE;
		$DB->change_message($messageid, $message, $name);
		
	}
	
	public function change_coment($messageid, $message, $name)
	{
		$DB = new $this->DBTYPE;
		$DB->change_coment($messageid, $message, $name);
		
	}
	
	public function DelMessage($id)
{
	
		$DB = new $this->DBTYPE;
		$DB -> DelMessage($id);
	
}
	
	public function DelComent($id)
{
	
			   $DB = new $this->DBTYPE;
			   $DB -> DelComent($id);
}
	
/**
 * 
 */	
	public function getAllMessages()
	{
	
		
		$DB = new $this->DBTYPE;
		$messages = array();
		$messages = $DB->getmessages();		
		return $messages;
		
		
	}
	
	public function getMessage($messageid)
	{
		$DB = new $this->DBTYPE;	
		$messages = array();
		$messages = $DB->getMessage($messageid);
		return $messages;
		
	}
	
	
	
	public function getAllComents($messageid)
	{
		$DB = new $this->DBTYPE;
		$coments = array();
		$coments = $DB->getAllComents($messageid);		
		return $coments;
	}
	
	public function getComments($messageid)
	{
		$DB = new $this->DBTYPE;
		$coments = array();
		$coments = $DB->getComments($messageid);		
		return $coments;
	}
   	
	
}